package com.dimong.loan.sdk.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.dimong.loan.sdk.app.BaseApplication;

public final class SharedUtil {
	private static final String sharedName = "loan";

	private SharedUtil() {
		throw new AssertionError();
	}

	public static void delAllPrefer(SharedPreferences paramSharedPreferences) {
		SharedPreferences.Editor editor = paramSharedPreferences.edit();
		editor.clear();
		editor.commit();
	}

	public static void delPrefer(Context paramContext, String paramString) {
		SharedPreferences.Editor editor = paramContext.getSharedPreferences(sharedName, 0).edit();
		editor.remove(paramString);
		editor.commit();
	}

	public static void delPrefer(Context context, String str1, String str2) {
		SharedPreferences.Editor editor = context.getSharedPreferences(str1, 0).edit();
		editor.remove(str2);
		editor.commit();
	}

	public static void delPrefer(SharedPreferences paramSharedPreferences, String paramString) {
		SharedPreferences.Editor editor = paramSharedPreferences.edit();
		editor.remove(paramString);
		editor.commit();
	}

	public static void setPreferStr(Context context, String str1, String str2) {
		SharedPreferences.Editor editor = context.getSharedPreferences(sharedName, 0).edit();
		editor.putString(str1, str2);
		editor.commit();
	}

	public static void setPreferBool(Context context, String str, boolean bool) {
		SharedPreferences.Editor editor = context.getSharedPreferences(sharedName, 0).edit();
		editor.putBoolean(str, bool);
		editor.commit();
	}

	public static void setPreferInt(Context context, String str, int i) {
		SharedPreferences.Editor editor = context.getSharedPreferences(sharedName, 0).edit();
		editor.putInt(str, i);
		editor.commit();
	}

	public static void setPreferLong(Context context, String str, long l) {
		SharedPreferences.Editor editor = context.getSharedPreferences(sharedName, 0).edit();
		editor.putLong(str, l);
		editor.commit();
	}

	public static void setPreferStr(Context context, String str1, String str2, String str3) {
		SharedPreferences.Editor editor = context.getSharedPreferences(str1, 0).edit();
		editor.putString(str2, str3);
		editor.commit();
	}

	public static void setPreferBool(Context context, String str1, String str2, boolean bool) {
		SharedPreferences.Editor editor = context.getSharedPreferences(str1, 0).edit();
		editor.putBoolean(str2, bool);
		editor.commit();
	}

	public static void setPreferInt(Context context, String str1, String str2, int i) {
		SharedPreferences.Editor editor = context.getSharedPreferences(str1, 0).edit();
		editor.putInt(str2, i);
		editor.commit();
	}

	public static void setPreferLong(Context context, String str1, String str2, long l) {
		SharedPreferences.Editor editor = context.getSharedPreferences(str1, 0).edit();
		editor.putLong(str2, l);
		editor.commit();
	}

	public static String getPrefer(SharedPreferences shared, String str) {
		return shared.getString(str, null);
	}

	public static boolean getPreferBool(Context context, String str, boolean bool) {
		return context.getSharedPreferences(sharedName, 0).getBoolean(str, bool);
	}

	public static boolean getPreferBool(String str, boolean bool) {
		return getPreferBool(BaseApplication.getApplication(), str, bool);
	}

	public static int getPreferInt(Context context, String str, int i) {
		return context.getSharedPreferences(sharedName, 0).getInt(str, i);
	}

	public static int getPreferInt(Context context, String str1, String str2, int i) {
		return context.getSharedPreferences(str1, 0).getInt(str2, i);
	}

	public static int getPreferInt(String str, int i) {
		return getPreferInt(BaseApplication.getApplication(), str, i);
	}

	public static long getPreferLong(Context context, String str, long l) {
		return context.getSharedPreferences(sharedName, 0).getLong(str, l);
	}

	public static long getPreferLong(String str, long l) {
		return getPreferLong(BaseApplication.getApplication(), str, l);
	}

	public static String getPreferStr(Context context, String str) {
		return context.getSharedPreferences(sharedName, 0).getString(str, null);
	}

	public static String getPreferStr(Context context, String str1, String str2) {
		return context.getSharedPreferences(str1, 0).getString(str2, null);
	}

	public static String getPreferStr(String str) {
		return getPreferStr(BaseApplication.getApplication(), str);
	}

	public static String getPreferStr(String str1, String str2) {
		return getPreferStr(BaseApplication.getApplication(), str1, str2);
	}

	public static int getPreferInt(String str1, String str2, int i) {
		return getPreferInt(BaseApplication.getApplication(), str1, str2, i);
	}

	public static void setPreferBool(String str, boolean bool) {
		setPreferBool(BaseApplication.getApplication(), str, bool);
	}

	public static void setPreferInt(String str, int i) {
		setPreferInt(BaseApplication.getApplication(), str, i);
	}

	public static void setPreferLong(String str, long l) {
		setPreferLong(BaseApplication.getApplication(), str, l);
	}

	public static void setPreferStr(String str1, String str2) {
		setPreferStr(BaseApplication.getApplication(), str1, str2);
	}

	public static void setPreferStr(String str1, String str2, String str3) {
		setPreferStr(BaseApplication.getApplication(), str1, str2, str3);
	}

	public static void saveIsFirstOpen(boolean isFirstOpen) {
		setPreferBool("FIRST_OPEN", isFirstOpen);
	}

	public static boolean getIsFirstOpen() {
		return getPreferBool("FIRST_OPEN", true);
	}
	public static void saveMyCity(String myCity) {
		setPreferStr("My_City", myCity);
	}

	public static String getMyCity() {
		return getPreferStr("My_City");
	}
	public static void saveMyLocation(String myCity) {
		setPreferStr("location", myCity);
	}

	public static String getMyLocation() {
		return getPreferStr("location");
	}
	public static void saveIsFirstXunmi(boolean isFirstOpen) {
		setPreferBool("FIRST_XUNMI", isFirstOpen);
	}

	public static boolean getIsFirstXunmi() {
		return getPreferBool("FIRST_XUNMI", true);
	}

	public static void saveIsFirstProductList(boolean isFirstProductList) {
		setPreferBool("FIRST_PRODUCT_LIST", isFirstProductList);
	}

	public static boolean getIsFirstProductList() {
		return getPreferBool("FIRST_PRODUCT_LIST", true);
	}

	public static void saveBoxIndicate(boolean isFirstOpen) {
		setPreferBool("MESSAGE_INDICATE", isFirstOpen);
	}

	public static boolean getBoxIndicate() {
		return getPreferBool("MESSAGE_INDICATE", false);
	}

	public static String getDpiFloat() {
		return getPreferStr("DPI_FLOAT");
	}

	public static int getDpiInt() {
		return getPreferInt("DPI_INT", 240);
	}

	public static int getScreenHeight() {
		return getPreferInt("SHEIGHT", 800);
	}

	public static int getScreenWidth() {
		return getPreferInt("SWIDTH", 480);
	}
}
